<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>其他样式的属性</title>
    <style>
      #box1 {
        width: 100px;
        height: 100px;
        background-color: red;
        padding: 10px;
        border: 10px solid #eee;
        margin-top: 10px;
      }
    </style>
  </head>
  <body>
    <button id="btn01">点我一下</button>
    <br />
    <div id="box1"></div>

    <script>
      var box1 = document.getElementById("box1");
      var btn01 = document.getElementById("btn01");

      btn01.onclick = function () {
        /*
        clientWidth
        clientHeight
        获取元素的可见宽度和高度，包括内容区和内边距
        都是只读的

        offsetWidth
        offsetHeight
        获取元素的整个宽度和高度，包括外边距border、内容区content和内边距padding
        
        当满足scrollHeight - scrollTop === clientHeight 说明垂直滚动条到底了，试用判断是否阅读协议完毕
        当满足scrollWidth - scrollLeft === clientWidth 说明水平滚动条到底了
        */
        alert(box1.offsetWidth);
      };
    </script>
  </body>
</html>
